import { directives } from '@/assets/index.ts'

const state = () =>({
  // horizontal：水平，vertical：垂直
  NavMenuMode:'horizontal',
  // 随机背景url,
  brakgroundImgUrl: '',
  // 随机背景图数组
  brakgroundImgList: directives
})

const mutations = {
  SET_MENUMODE(state, menuMode){
    state.NavMenuMode = menuMode
  },

  SET_BRAKGROUNDIMGURL(state, path){
    state.brakgroundImgUrl = path
  }
}

const actions = {
  setBarkgroundPath({commit}){
    let imgLenght = state().brakgroundImgList.length;
    let index = Math.floor(Math.random()*imgLenght);
    let path = state().brakgroundImgList[index]['imgUrl'];
    commit('SET_BRAKGROUNDIMGURL', path);
    return path
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}